package com.cxj.link;

import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
import com.cxj.link.util.LogUtil;
import java.util.HashMap;

public class SoundsManager {
    public static final int SOUND_BOMB = 2;
    public static final int SOUND_EARSE = 3;
    public static final int SOUND_HINT = 4;
    public static final int SOUND_REFRESH = 5;
    public static final int SOUND_SELECT = 1;
    private static SoundPool soundPool;
    private static HashMap<Integer, Integer> soundPoolMap;

    public static void destroy() {
        if (soundPool != null) {
            soundPool.release();
            soundPool = null;
        }
        soundPoolMap = null;
    }

    public static SoundPool getSoundPool() {
        if (soundPool == null)
            soundPool = new SoundPool(6, 3, 100);
        return soundPool;
    }

    public static HashMap<Integer, Integer> getSoundPoolMap() {
        if (soundPoolMap == null)
            soundPoolMap = new HashMap();
        return soundPoolMap;
    }

    public static void initSoundPoolMap(Context paramContext) {
        getSoundPoolMap();
        getSoundPool();
        soundPoolMap.put(Integer.valueOf(SOUND_SELECT),
                Integer.valueOf(soundPool.load(paramContext, R.raw.select, SOUND_SELECT)));
        soundPoolMap.put(Integer.valueOf(SOUND_BOMB),
                Integer.valueOf(soundPool.load(paramContext, R.raw.bomb, SOUND_BOMB)));
        soundPoolMap.put(Integer.valueOf(SOUND_REFRESH),
                Integer.valueOf(soundPool.load(paramContext, R.raw.refresh, SOUND_REFRESH)));
    }

    public static void playSound(Context paramContext, int paramInt) {
        if (Setting.audio) {
            LogUtil.info("playSound:" + paramInt);
            AudioManager localAudioManager = (AudioManager) paramContext.getSystemService("audio");
            float f = localAudioManager.getStreamVolume(3) / localAudioManager.getStreamMaxVolume(3);
            soundPool.play(soundPoolMap.get(Integer.valueOf(paramInt)).intValue(), f, f, 1, 0, 1.0F);
        }
    }
}
